<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/adminHome.css" rel="stylesheet" type="text/css"/>
<title>Home</title>

<script>
function hideDiv(div) {
	document.getElementById(div).style.display = "none";
	document.getElementById('menu').style.display = "block";
}
function showDiv(div) {
	document.getElementById(div).style.display = "block";
	document.getElementById('menu').style.display = "none";
}
</script>

</head>

<body>
	
<?php
	include_once('functions/getDateInformation.php');
	$date = date("d-m-Y");
	$month = getMonth($date);
	$monthName = getMonthName($month);
	$prevMonth = getPrevMonth($date);
	$prevMonthName = getMonthName($prevMonth);
	
?>
	
    
<div class="container">
<br /><br /> 
	<?php
		include_once('frontend/header.php');
	?>
	<br /><br /> 
	<div id="navlist">
		<ul>
		  <li><a href="#proyectos" onclick="showDiv('projectCharge')" >Proyectos</a></li>
		  <li><a href="#reporte"   onclick="showDiv('projectsCosts')" >Reporte</a></li>
		  <li><a href="#carga">Carga horaria</a></li>
		</ul>
	</div>
	<!--
	<div class="menu" id="menu">
       <br /><br /> 
       <input type="button" value="Dar de alta un nuevo recurso" onclick="showDiv('resourceCharge')"  /><br />
       <input type="button" value="Editar un recurso" onclick="showDiv('resourceModify')"  /><br /><br />
       <input type="button" value="Ver estado de usuarios" onclick="showDiv('resourcesState')"  /><br /><br />
       <input type="button" value="Ver costos de los proyectos de <?php echo $prevMonthName ?>" onclick="showDiv('projectsCosts')"  /><br />
       <br /><br /><br />
   </div>
	-->
    <div class="charge" align="center">
        <div  class="projectCharge" id="projectCharge" style="display:none; border:1px solid;width: 500px;">
			 <a class="boldText">Crear proyecto:</a><br /><br /> 
			 
			<form action="adminsCharge.php" method="post">
				<table width="300" border="0" cellspacing="1" cellpadding="9">
				<tr>
				<td>Nombre del proyecto:</td>
				<td><input name="name" type="text" /></td>
				<td>Proyecto solicitado:</td>
					<td><?php echo"<select>
										  <option value=\"hardcodeado\">hardcodeado</option>
										</select>" ?>	
					</td>
				</tr>
				</table>
				<input type="hidden" name="user" value="<?php echo $user?>" />
				<input name="project" type="hidden" value="" />
		  
				<br />
				<input type="submit" value="Crear" /><input type="button" value="Cancelar" onclick="hideDiv('projectCharge')" /> 
			</form>
			<br /><br /><br />
			<a class="boldText">Borrar proyecto</a><br /><br />     
			<form action="TODO" method="post">
				<table width="300" border="0" cellspacing="1" cellpadding="9">
				<tr>
				<td>Lista de proyectos:</td>
					<td><?php echo"<select>
										  <option value=\"hardcodeado\">hardcodeado</option>
										</select>" ?>	
					</td>
				</tr>
				</table>
				<input type="hidden" name="user" value="<?php echo $user?>" />
				<input name="project" type="hidden" value="" />
		  
				<br />
				<input type="submit" value="Borrar" /><input type="button" value="Cancelar" onclick="hideDiv('projectCharge')" /> 
			</form>
			<br /><br /><br />
			
		</div>
    
	
	
    <div class="resourceCharge" id="resourceCharge" style="display:none">
        <a class="boldText">Nuevo recurso:</a><br /><br /> 
        <form action="adminsCharge.php" method="post">     
            <table width="300" border="0" cellspacing="1" cellpadding="9">
            <tr class="row">
            <td>Nombre:</td>
            <td><input name="name" type="text" /></td>
            </tr>
            <tr class="row">
            <td>Apellido:</td>
            <td><input name="surname" type="text" /></td>
            </tr>
            <tr class="row">
            <td>Dni:</td>
            <td><input name="dni" type="text" /></td>
            </tr>
            <tr class="row">
            <td>Correo Electronico:</td>
            <td><input name="mail" type="text" /></td>
            </tr>
            <tr class="row">
            <td>Sueldo:</td>
            <td><input name="salary" type="text" /></td>
            </tr>
            </table>
            <input type="hidden" name="user" value="<?php echo $user?>" />
            <input name="resource" type="hidden" value="" />
        
   			<br />       
        	<input type="submit" value="Crear" /><input type="button" value="Cancelar" onclick="hideDiv('resourceCharge')" /> 
        </form>
    </div>
      <div class="resourceModify" id="resourceModify" style="display:none">
         <a class="boldText">Modificar recurso:</a><br /><br /> 
        <?php		
			$query = "SELECT name, surname, dni, mail, salary FROM users WHERE user = 'alan33209812'"; 
			$result = mysqli_query($connection, $query); 
			$row = mysqli_fetch_array($result);
			$name = $row['name'];
			$surname = $row['surname'];
			$dni = $row['dni'];
			$mail = $row['mail'];
			$salary = $row['salary'];
        ?> 
        
        <form action="adminsCharge.php" method="post">     
            <table width="300" border="0" cellspacing="1" cellpadding="9">
            <tr class="row">
            <td>Nombre:</td>
            <td><input name="name" type="text" value="<?php echo $name?>" /></td>
            </tr>
            <tr class="row">
            <td>Apellido:</td>
            <td><input name="surname" type="text" value="<?php echo $surname?>" /></td>
            </tr>
            <tr class="row">
            <td>Dni:</td>
            <td><input name="dni" type="text" value="<?php echo $dni?>" /></td>
            </tr>
            <tr class="row">
            <td>Correo Electronico:</td>
            <td><input name="mail" type="text" value="<?php echo $mail?>" /></td>
            </tr>
            <tr class="row">
            <td>Sueldo:</td>
            <td><input name="salary" type="text" value="<?php echo $salary?>" /></td>
            </tr>
            </table>
            <input type="hidden" name="user" value="<?php echo $user?>" />
            <input name="modifyResource" type="hidden" value="" />
        
   			<br />       
        	<input type="submit" value="Modificar" /><input type="button" value="Cancelar" onclick="hideDiv('resourceModify')" /> 
        </form>
    	</div>
        <div class="resourcesState" id="resourcesState" style="display:none">
        <a class="boldText">Usuarios que no han actualizado la carga de horarios de </a><?php echo "<a class='blueText'>$prevMonthName</a>" ?>:<br /><br /> 
                <table width="200" border="0" cellspacing="1" cellpadding="9">
                <tr class="row boldText">
                <td>Nombre</td>
           		<td>Apellido</td>
                <td>DNI</td>
           		</tr>
				<?php		
					$query = "SELECT name, surname, dni FROM users WHERE updated = '0'"; 
					$result = mysqli_query($connection, $query); 
					$i = 0;
					while ($row = mysqli_fetch_array($result)) {
						echo "<tr class='row'><td>$row[name]</td>";
						echo "<td>$row[surname]</td>";
						echo "<td>$row[dni]</td></tr>";
						$i++;      
					}	
        		?>    
        	 	</table><br />
                <input type="button" value="Volver" onclick="hideDiv('resourcesState')" /> 
    	</div>
       
	   <div class="projectsCosts" id="projectsCosts" style="display:none; border:1px solid;width: 500px;">
        
		<a class="boldText">Costos de los proyectos de </a><?php echo "<a class='blueText'>$prevMonthName</a>" ?>:<br/><br/> 
                
				
				<table width="450" border="0" cellspacing="1" cellpadding="9" align="center" >
                <tr >
                <td>Codigo del proyecto</td>
                <td>Nombre</td>
           		<td>Costo</td> 
                <td>Cantidad de participantes</td>
           		</tr>
				<?php		
					include_once('functions/costCalculation.php');
					list($projects, $projectsNames, $consultancies, $consultanciesNames, $projectsCosts, $consultanciesCosts, $projectMembers, $consultancyMembers) = calculateCostPerProject($date);
					$cnt = 0;
					foreach ($projects as $project){
						echo "<tr>";
						echo "<td>$project</td><td>$projectsNames[$cnt]</td><td>$ $projectsCosts[$project]</td><td>$projectMembers[$project]</td>";
						echo "</tr>";
						$cnt++;
					}
        		?>    
        	 	</table><br />
				
                <input type="button" value="Volver" onclick="hideDiv('projectsCosts')" /> <input type="button" value="Exportar reporte actual" onclick="TODO" /> 
    	</div>
   
 	    
</div>
    

	
</body>
</html>
